using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using UMEVOR.BLL;
using UMEVOR.DTO;
using UMEVOR.VO;

public partial class Portal_Noticia : System.Web.UI.Page
{
    int codigo;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack && !this.IsCallback)
        {
            if (!Request.QueryString["id"].Equals(""))
            {
                codigo = Int32.Parse(Request.QueryString["id"]);
                Session["id"] = codigo;

                BLLT_NOTICIA bllNoticia = new BLLT_NOTICIA();
                T_NOTICIA noticia = bllNoticia.obterPorPK(codigo);

                dNoticia.InnerHtml = noticia.TX_DESC_NOTICIA.Replace("#", "<BR>");

                if (!noticia.TX_URL_FOTO_GRDE.Equals(""))
                {
                    String[] caminho = noticia.TX_URL_FOTO_GRDE.Split('\\');
                    //imgNoticia.ImageUrl = "..\\" + ConfigurationManager.AppSettings["DIR_IMAGENS"].ToString() + caminho[caminho.Length - 1];
                    imgNoticia.ImageUrl = "..\\" + caminho[caminho.Length - 1];
                }
                else
                    imgNoticia.ImageUrl = "../images/imagemNaoDisponivel.Jpg";

                lblTitulo.Text = noticia.TX_TITULO;
                lblFonte.Text = noticia.TX_FONTE;
                lblRedator.Text = noticia.TX_REDATOR;
                lblPostagem.Text = "Postagem: " + noticia.DT_INS_NOTICIA.ToString("dd/MM/yyyy");

                
                T_HIST_NOTICIA histNoticia = new T_HIST_NOTICIA();
                histNoticia.ID_NOTICIA = noticia.ID_NOTICIA;
                histNoticia.DT_ACESSO = DateTime.Now;
                BLLT_HIST_NOTICIA bllHistorico = new BLLT_HIST_NOTICIA();
                bllHistorico.incluir(histNoticia);
            }
        }
    }
}
